package com.ufind.server.controller;

import com.ufind.common.constant.ConstCommonString;
import com.ufind.common.response.Response;
import com.ufind.server.facade.UserFacade;
import com.ufind.server.facade.dto.request.RegisterCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

/**
 * 登陆用户控制器
 * @author xuliugen
 */
@Controller
@RequestMapping(produces = {ConstCommonString.APP_JSON_UTF_8})
public class LoginController {

    private static final Logger logger = LoggerFactory.getLogger(LoginController.class);

    @Inject
    private UserFacade userFacade;

    /**
     * 用户注册
     * @param request         http请求
     * @param registerCommand 注册的command
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public Response register(HttpServletRequest request, RegisterCommand registerCommand) {
        return userFacade.register(registerCommand);
    }
}
